<template>
	<!-- 修改密码 -->
	<view class="content">
		<view class="input-group">
			<view class="input-row">
				<text class="title">新密码:</text>
				<input class="input" v-model="password1" type="text" placeholder="请输入新密码">
			</view>
			<view class="input-row">
				<text class="title">确认密码:</text>
				<input class="input" v-model="password2" type="text" placeholder="请确认新密码">
			</view>
			<view class="btn-row">
				<button class="btn" @tap="findPassword">提交</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				acc:'',password1:'',password2:''
			}
		},
		onLoad(option){
			this.acc = option.account;
		},
		methods: {
			async findPassword() {
				var password1 = this.password1.replace(/\s*/g,"")
				var password2 = this.password2.replace(/\s*/g,"")
				if(password1 == password2){
					const res =await this.Request({
						url:'/api/employee/upemppass',
						method:'PUT',
						data:{password:this.password2,account:this.acc}
					})
					if(res){
						uni.showToast({
							icon: 'success',
							title: '修改成功',
							duration:500
						});
						setTimeout(() =>{
							uni.navigateTo({
								url:'/pages/super/superpage/empment'
							})
						},500)
					}
				}else{
					uni.showToast({
						icon: 'error',
						title: '两次输入的密码不同，请重试',
					});
					this.password2 = ''
				}
			}
		}
	}
</script>

<style lang="scss">
	.content{
		.input-group{
			height: 60px;
			width: 100%;
			margin-top: 50px;
			.input-row{
				position: relative;
				margin-left: 5%;
				width: 90%;
				height: 40px;
				margin-top: 10px;
				display: flex;
				border-radius: 5px;
				border: 1px solid #dadadd;
				background-color: #98d5c6;
				.title{
					margin: auto 0;
				}
				.input{
					position: absolute;
					margin-top: 8px;
					margin-left: 85px;
				}
			}
		}
		.btn-row{
			margin-top: 20px;
			.btn{
				width: 90%;
				background-color: #ffa53d;
			}
		}
	}
</style>
